import request from '@/utils/request'

const prePath = '/doc'
// 作废文档列表
export function getCancellationList(data) {
  return request({
    url: prePath + '/file/cancel/page',
    method: 'post',
    data,
  })
}
// 删除一条数据
export function removeCollection(id) {
  return request({
    url: prePath + '/fileLookup/collection/' + id,
    method: 'put',
  })
}
// 获取作废人（获取所有用户）
export function getPersons() {
  return request({
    url: prePath + '/system/user/all',
    method: 'get',
    // status： 0 未停用  del: 0 未删除
    params: { status: '0', del: 0 },
  })
}
// 查询文件类别列表
export function getCategoryListSelect(params) {
  return request({
    url: prePath + '/fileCategory/list',
    method: 'get',
    params,
    loadingAbled: false,
  })
}
// 查询文件类别列表-获取有查询和上传权限列表
export function getCategoryListHasViewAndUpload(params) {
  return request({
    url: prePath + '/fileCategory/listHasView',
    method: 'get',
    params,
  })
}
// 根据id获取详情查询文件类别详情
export function getCategoryDetail(id) {
  return request({
    url: prePath + '/fileCategory/detail/' + id,
    method: 'get',
  })
}
// 根据id删除文件类别
export function deleteCategoryById(id) {
  return request({
    url: prePath + '/fileCategory/' + id,
    method: 'delete',
  })
}
// 更新文件类别
export function updateCategory(data) {
  return request({
    url: prePath + '/fileCategory/update',
    method: 'put',
    data,
  })
}
// 新增文件类别
export function addCategory(data) {
  return request({
    url: prePath + '/fileCategory/add',
    method: 'post',
    data,
  })
}
// 批量删除员工排班
export function delScheduling(data) {
  return request({
    url: prePath + '/fileCategory/schedulingMain',
    method: 'delete',
    data: data,
  })
}
// 查询文件授权列表
export function getCheckList(params) {
  return request({
    url: prePath + '/fileUserMapper/page',
    method: 'get',
    params,
  })
}
// 查询文件未授权列表
export function getCheckNotList(params) {
  return request({
    url: prePath + '/fileUserMapper/notBindPage',
    method: 'get',
    params,
  })
}
// 新增授权
export function addCheck(data) {
  return request({
    url: prePath + '/fileUserMapper',
    method: 'post',
    data,
  })
}
// 删除授权
export function removeCheck(data) {
  return request({
    url: prePath + '/fileUserMapper',
    method: 'delete',
    data,
  })
}
// 文件下载授权
export function updateAuthoriseDownload(data) {
  return request({
    url: prePath + '/fileUserMapper/updateAuthoriseDownload',
    method: 'put',
    data,
  })
}
// 文件查看授权
export function updateAuthoriseView(data) {
  return request({
    url: prePath + '/fileUserMapper/updateAuthoriseView',
    method: 'put',
    data,
  })
}
// 查询人员与计划绑定-分页
export function getPaperSchemePermissionList(params) {
  return request({
    url: prePath + '/trainUserSchemeMapping/page',
    method: 'get',
    params,
  })
}
// 查询人员未过期且拥有权限的计划
export function getUserSchemePermissionList(params) {
  return request({
    url: prePath + '/trainUserSchemeMapping/pageUserSchemePermission',
    method: 'get',
    params,
  })
}
// 新增人员与试卷绑定
export function addPaperSchemeAuth(data) {
  return request({
    url: prePath + '/trainUserSchemeMapping',
    method: 'post',
    data,
  })
}
// 删除培训人员与计划绑定,支持批量删除
export function removeTrainUserScheme(data) {
  return request({
    url: prePath + '/trainUserSchemeMapping',
    method: 'delete',
    data,
  })
}
// 查询人员与试卷绑定-分页
export function getPaperAuthList(params) {
  return request({
    url: prePath + '/trainUserPaperMapping/page',
    method: 'get',
    params,
  })
}
// 查询有权限的试卷-分页
export function getPaperPermissionList(params) {
  return request({
    url: prePath + '/trainUserPaperMapping/pagePaperPermission',
    method: 'get',
    params,
  })
}
// 新增人员与试卷绑定
export function addPaperAuth(data) {
  return request({
    url: prePath + '/trainUserPaperMapping',
    method: 'post',
    data,
  })
}
// 删除培训人员与试卷绑定,支持批量删除
export function removePaperAuth(data) {
  return request({
    url: prePath + '/trainUserPaperMapping',
    method: 'delete',
    data,
  })
}
// 收藏记录列表
export function getCollectionList(params) {
  return request({
    url: prePath + '/fileLookup/getMyCollection',
    method: 'get',
    params,
  })
}
// 发布文档列表分页查询
export function getFile(data) {
  return request({
    url: prePath + '/file/search/page',
    method: 'post',
    data,
    loadingAbled: false,
  })
}
// 最近阅读列表
export function getLatest() {
  return request({
    url: prePath + '/file/latest/view',
    method: 'get',
    loadingAbled: false,
  })
}
// 大家都在看列表
export function getPopular() {
  return request({
    url: prePath + '/file/popular',
    method: 'get',
    loadingAbled: false,
  })
}
// 文件下载
export function downloadFile(id) {
  return request({
    url: prePath + '/file/download/' + id,
    method: 'post',
  })
}
// 文档查看申请
export function approval(data) {
  return request({
    url: prePath + '/file/view/approval',
    method: 'post',
    data,
  })
}
// 文档查看驳回申请
export function approvalFlow(data) {
  return request({
    url: prePath + '/file/view/approval',
    method: 'put',
    data,
  })
}
// 历史版本查询
export function getHistory(id) {
  return request({
    url: prePath + '/file/history/' + id,
    method: 'get',
  })
}
// 生命周期查询
export function getRecord(id) {
  return request({
    url: prePath + '/file/operate/record/' + id,
    method: 'get',
  })
}
// 置顶
export function getTop(id, params) {
  return request({
    url: prePath + '/file/top/' + id,
    method: 'get',
    params,
  })
}
// 查询文件类别列表
export function getCategoryList() {
  return request({
    url: prePath + '/fileCategory/list',
    method: 'get',
  })
}
// 查询上传统计列表
export function getUploadList(params) {
  return request({
    url: prePath + '/fileStatistics/fileUpload',
    method: 'get',
    params: params,
  })
}
// 查询查看统计列表
export function getViewsList(params) {
  return request({
    url: prePath + '/fileStatistics/fileRead',
    method: 'get',
    params: params,
  })
}
// 查询下载统计列表
export function getMyDownloadList(params) {
  return request({
    url: prePath + '/fileStatistics/fileDownload',
    method: 'get',
    params: params,
  })
}
// 查询作废统计列表
export function getCancelList(params) {
  return request({
    url: prePath + '/fileStatistics/fileCancel',
    method: 'get',
    params: params,
  })
}
// 查询收藏统计列表
export function getCollectList(params) {
  return request({
    url: prePath + '/fileStatistics/fileCollection',
    method: 'get',
    params: params,
  })
}
// 查询发布统计列表
export function getPublishList(params) {
  return request({
    url: prePath + '/fileStatistics/fileGroupingStatistics',
    method: 'get',
    params: params,
  })
}
// 文件详情
export function getDetail(params) {
  let url = prePath + '/file/detail/' + params.id
  if (params.source) {
    url += '?source=' + params.source
  }
  return request({
    url,
    method: 'get',
  })
}
// 文件作废
export function cancelFile(data) {
  return request({
    url: prePath + '/file/cancel',
    method: 'put',
    data,
  })
}
// 文件取消作废
export function cancelVoidFile(data) {
  return request({
    url: prePath + '/file/uncancel',
    method: 'put',
    data,
  })
}
// 收藏一条数据
export function collectFile(params) {
  return request({
    url: prePath + '/file/operate/collect/' + params.fileId,
    method: 'get',
    params,
  })
}
// 文件恢复
export function reCancelFile(fileId) {
  return request({
    url: prePath + '/file/recovery/' + fileId,
    method: 'put',
  })
}
// 文件撤回
export function revokeFile(data) {
  return request({
    url: prePath + '/file/revoke',
    method: 'put',
    data,
  })
}
// 获取文件编辑地址
export function getFileUrl(params) {
  return request({
    url: prePath + '/office/editOfficeFile',
    method: 'get',
    params,
  })
}
// 文件阅读时长
export function setDuration(params) {
  return request({
    url:
      prePath +
      '/file/read/duration/' +
      params.fileId +
      '/' +
      params.readFlowId,
    method: 'get',
    params,
  })
}
// 文件加锁操作
export function lock(data) {
  return request({
    url: prePath + '/file/lock/' + data.id + '?lock=' + data.lock,
    method: 'put',
  })
}
// 查询文件组合列表
export function getGroupList(params) {
  return request({
    url: prePath + '/filePortfolio/page',
    method: 'get',
    params,
  })
}
// 根据组合id查询绑定的类别信息(字段中包含所有类别)
export function getGroupTree(id) {
  return request({
    url: prePath + '/fileCategoryPortfolioMapper/selectByPortfolioId/' + id,
    method: 'get',
  })
}
// 查询组合已授权人员
export function getGroupDetail(id) {
  return request({
    url: prePath + '/portfolioUserMapper/selectByPortfolioId/' + id,
    method: 'get',
  })
}
// 根据id删除文件组合
export function deleteGroupById(id) {
  return request({
    url: prePath + '/filePortfolio/' + id,
    method: 'delete',
  })
}
// 更新文件组合
export function updateGroup(data) {
  return request({
    url: prePath + '/filePortfolio/update',
    method: 'put',
    data,
  })
}
// 更新文件类别
export function updateGroupCate(data) {
  return request({
    url: prePath + '/fileCategoryPortfolioMapper/updateList',
    method: 'post',
    data,
  })
}
// 组合中修改人员
export function updateGroupPerson(data) {
  return request({
    url: prePath + '/portfolioUserMapper/updateList',
    method: 'post',
    data,
  })
}
// 新增文件类别
export function addGroup(data) {
  return request({
    url: prePath + '/filePortfolio/add',
    method: 'post',
    data,
  })
}
// 查询授权组合列表
export function filePortfolio(params) {
  return request({
    url: prePath + '/filePortfolio/page',
    method: 'get',
    params,
  })
}
// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: prePath + '/system/dept/treeselect',
    method: 'get',
  })
}
// 查询用户列表
export function listUser(query) {
  return request({
    url: prePath + '/system/user/list',
    method: 'get',
    params: query,
  })
}
// 查询发布文档列表
export function getPublishListPage(data) {
  return request({
    url: prePath + '/file/publish/page',
    method: 'post',
    data,
  })
}
// 发布文档
export function publishFile(data) {
  return request({
    url: prePath + '/file/publish',
    method: 'post',
    data,
  })
}
// 取消发布文档
export function publishVoidFile(data) {
  return request({
    url: prePath + '/file/unpublish',
    method: 'post',
    data,
  })
}
// 根据id获取文件详情信息
export function getFileDetail(id) {
  return request({
    url: prePath + '/file/detail/' + id,
    method: 'get',
  })
}
// 文件上传前处理
export function preUpload() {
  return request({
    url: prePath + '/file/preUpload',
    method: 'post',
  })
}
// 查询我的上传列表
export function getMyUploadList(params) {
  return request({
    url: prePath + '/sysFile/selectByAction',
    method: 'get',
    params,
  })
}
// 提交上传
export function addUpload(data) {
  return request({
    url: prePath + '/sysFile/commit',
    method: 'post',
    data: data,
  })
}
// 取消上传
export function unUpload(id) {
  return request({
    url: prePath + '/sysFile/uncommit/' + id,
    method: 'post',
  })
}
// 根据id获取文件详情信息
export function getFileDetailById(id) {
  return request({
    url: prePath + '/sysFile/' + id,
    method: 'get',
  })
}
// 删除一条数据
export function removeUpload(id) {
  return request({
    url: prePath + '/sysFile/' + id,
    method: 'delete',
  })
}
// 删除一条数据文件
export function removeUploadFile(params) {
  return request({
    url: prePath + '/sysFile/delete',
    method: 'delete',
    params
  })
}
// 根据id获取文件详情信息
export function getUploadDetail(params) {
  return request({
    url: prePath + '/sysFile/selectByAction',
    method: 'get',
    params,
  })
}
// 文件上传
export function uploadFile(data) {
  return request({
    url: prePath + '/sysFile',
    method: 'post',
    data,
  })
}
// 文件上传
export function editFile(data) {
  return request({
    url: prePath + '/sysFile',
    method: 'put',
    data,
  })
}
// 文件重传
export function reUpload(data) {
  return request({
    url: prePath + '/file/reUpload',
    method: 'post',
    data,
  })
}
// 我的下载列表
export function getMyDownloads(params) {
  return request({
    url: prePath + '/fileLookup/getMyDownloads',
    method: 'get',
    params,
  })
}
// 文件移动
export function moveFile(params) {
  return request({
    url: prePath + '/file/move/' + params.id,
    method: 'get',
    params,
  })
}
// 文件复制
export function copyFile(params) {
  return request({
    url: prePath + '/file/copy/' + params.id,
    method: 'get',
    params,
  })
}
// 文件复制
export function getFileBlob(url) {
  return request({
    url,
    method: 'get',
    responseType: 'blob',
  })
}
